#include <thread>
#include <iostream>
#include <vector>
#include <functional>
#include <atomic>
using namespace std;

//counter()函数接受两个整数
void counter(int id,int numIterations)
{
    for(int i = 0;i < numIterations;++i){
        cout << "Counter " << id << " has value ";
        cout << i << endl;
    }
}

int main()
{
    cout.sync_with_stdio(true);     //Make sure cout is thread-safe
    thread t1(counter,1,6);
    thread t2(counter,2,4);
    t1.join();
    t2.join();
    return 0;
}

